﻿/*
 * Copyright (c) 2009, 北京理工大学  王柳茗
 * All rights reserved.
 *
 * $Revision$
 *
 * $Author$
 *
 * $Date$
 *
 * $Log$
 *
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace wlm.wsx
{
    /// <summary>
    /// Parser Class
    /// </summary>
    public class Parser
    {
        public Parser(Scanner s)
        {
            _Scanner = s;
        }
        
        /// <summary>
        /// 实际上应该返回Tree
        /// </summary>
        public Operator Parse()
        {
            while (true )
            {
                switch  (_Scanner.Token)
                {
                    case Tokens.PLUS :
                        return new PlusOperator (_Scanner.Operator1 , _Scanner.Operator2);
                    case Tokens .MINUS :
                        return new MinusOperator(_Scanner.Operator1, _Scanner.Operator2);
                    case Tokens .EOF :
                        return null;
                }
                _Scanner.NextToken();
            }
        }

        private Scanner _Scanner;
    }
}
